/*
 * @Date: 2022-02-11 16:17:04
 * @LastEditors: tich425
 * @LastEditTime: 2022-02-11 17:11:47
 * @FilePath: \TodoList\model\user.go
 * @Description: user
 */
package model

import (
	"todo-list/global"

	"gorm.io/gorm"
)

type Email struct {
	Email string `json:"email" binding:"email"` // 邮箱
}

type Regist struct {
	Username   string `json:"username" binding:"min=4,max=16"`   // 登录名
	Password   string `json:"password" binding:"min=6,max=18"`   // 密码
	Email      string `json:"email" binding:"email"`             // 邮箱
	VerifyCode string `json:"verify_code" binding:"min=6,max=6"` // 验证码
}

type Login struct {
	Username string `json:"username" binding:"min=4,max=16"`
	Password string `json:"password" binding:"min=6,max=18"`
}

/**
 * @description: users 数据表
 */
type User struct {
	gorm.Model
	Username string // 登录名
	Password string // 密码
	Email    string // 邮箱
	IsSuper  bool   `gorm:"default:false"` // 是否为超级管理员
	// Avatar   string `gorm:"default:'/headfile/fzf404.jpg'"` // 头像
}

/**
 * @description: 创建用户
 */
func (u *User) Create() {
	global.MYSQL_DB.Create(&u)
}

type UserDto struct {
	ID       uint   `json:"uid"`
	Username string `json:"username"`
	Email    string `json:"email"`
	IsSuper  bool   `json:"is_super"`
	// Avatar   string `json:"avatar"`
}
